#include<bits/stdc++.h>
using namespace std;
const int nmax=100000+10;
int T;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    while(T--){
        int n,m,L,V,ansa=0,ansb=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        int d[nmax],v[nmax],a[nmax],det[nmax];
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++)scanf("%d",&det[i]);
        sort(det+1,det+m+1);

        for(int i=1;i<=n;i++){
  //          for(int j=1;j<=m;j++){
    //            if(a[i]==0){
      //              if(v[i]>V){
        //                ans1++;
          //              isyun=1;
            //        }
              //      break;
                //}

           /*     int dis=det[j]-d[i];
                if(dis<0)continue;
                int pv;
                pv=v[i]*v[i]+2*a[i]*dis;
                if(pv<0)break;
                if(pv>(V*V)){
                    ans1++;
                    check[j]=1;
                    break;
                }
            }*/
            int dis=det[m]-d[i];
            if(dis<0)continue;
            int pv=v[i]*v[i]+2*a[i]*dis;
            if(pv>(V*V)){
                ansa++;
            }
        }
        if(ansa!=0)ansb=m-1;
        else ansb=m;
        printf("%d %d\n",ansa,ansb);
    }
return 0;
}
